package com.neuedu.hisadmin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neuedu.hisadmin.dto.DoctorScheduleDTO;
import com.neuedu.hisadmin.entity.Scheduling;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jaun
 * @since 2025-07-05
 */
@Mapper
public interface SchedulingMapper extends BaseMapper<Scheduling> {

        @Select(
                "SELECT " +
                "s.SchedDate AS schedDate, " +
                "d.DeptName AS deptName, " +
                "u.RealName AS realName, " +
                "s.Noon AS noon, " +
                "r.RegistName AS registName, " +
                "r.RegistFee AS registFee, " +
                "r.RegistQuota AS registQuota " +
                "FROM scheduling s " +
                "INNER JOIN user u ON s.UserID = u.ID " +
                "INNER JOIN department d ON s.DeptID = d.ID " +
                "INNER JOIN registlevel r ON u.RegistLeID = r.ID " +
                "WHERE " +
               "d.DeptName LIKE CONCAT('%', #{deptName}, '%') " + // 模糊匹配科室
                "AND u.RealName LIKE CONCAT('%', #{doctorName}, '%') " + // 模糊匹配医生
                "AND r.RegistName LIKE CONCAT('%', #{registLevel}, '%') " + // 模糊匹配挂号级别
                "AND s.DelMark = 1 " +
                "AND u.DelMark = 1 " +
                "AND d.DelMark = 1 " +
              "AND r.DelMark = 1"
             )




        List<DoctorScheduleDTO> findDoctorSchedules(
                @Param("deptName") String deptName,
                @Param("doctorName") String doctorName,
                @Param("registLevel") String registLevel);
               // @Param("currentDate")LocalDate currentDate);
}
